{% extends "base.html" %}
{% block body %}
<script>
$(document).ready(function(){
  $(".modify_message_form").hide();
  $(".delete_message").click(
  function(){
        window.location.href = "{{url_for("delete_message")}}" + "?message_id="
        + $(this).attr("message_id") + "&page=" + "{{page}}";
  });
  $(".modify_message_info").click(
  function(){
      $(".modify_message_form").hide();
      $(this).parent().next('div[class=modify_message_form]').show();
  });
});

</script>
{% from "_formhelpers.html" import render_field %}
{% for message in messages %}

<div id="message">
    <div id="message_attr">网友:{{message.nickname}}
        <span id="post_time">
       发表日期:
        {{time_to_str(message.submit_time)}}
       </span>
    </div>
    <div id="message_body"><b>{{message.message}}</b></div>
    <div class="modify_message">
        <b class="delete_message" message_id={{message.uuid}}>删除</b>
        <b class="modify_message_info" message_id={{message.uuid}}>修改</b>
    </div>
    <div class="modify_message_form" id={{message.uuid}}>
        <form action="" method="post" name="MessageForm">
            {{form.hidden_tag()}}
            <p>
                {{render_field(form.nickname)}}
            </p>
            <p>
                {{render_field(form.message_submitted,rows=5, cols=100)}}
            </p>
            <p>
                <input id="uuid" name="uuid" type="hidden" value="{{message.uuid}}"/>
            </p>
            <p><input type="submit" value="提交"></p>
        </form>
    </div>
</div>
<br/>
{% endfor %}
<br/>

<div>
    <form action="" method="post" name="MessageForm">
        {{form.hidden_tag()}}
        <p>
            {{render_field(form.nickname)}}
        </p>
        <p>
            {{render_field(form.message_submitted,rows=5, cols=100)}}
           <script>
            $(function(){
            window.CKEDITOR_BASEPATH = "{{url_for(".static", filename='ckeditor/')}}";
if (CKEDITOR.instances['textarea#message_submitted']) {
CKEDITOR.remove(CKEDITOR.instances['textarea#message_submitted']);
}

$('textarea#message_submitted').ckeditor(
function() {
},
{
removePlugins: 'elementspath',
toolbar : 'Basic'
}
);


            }
            )
            </script>
        </p>

        <p>
            <input id="uuid" name="uuid" type="hidden" value="add_message"/>
        </p>
        <p><input type="submit" value="提交"></p>
    </form>
</div>
{% endblock %}
